package com.aurora.color;


import static android.graphics.Color.parseColor;
import static com.aurora.color.Utils.*;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.aurora.color.adapter.ZiListAdapter;


public class ColorDetail extends AppCompatActivity {

    private ListView listView;

    //父颜色名称
    private String[] fColor;

    //子颜色数组
    private String[] zColor;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_color_detail);

        //接收子颜色数组
        rxd();

        //设置状态栏
        setBarColor(this, parseColor(fColor[1]));

        //设置父颜色标题
        TextView tv_title = findViewById(R.id.item_ld_title);
        tv_title.setText(fColor[0]);
        //导航栏背景
        RelativeLayout bar = findViewById(R.id.item_ld_bar);
        bar.setBackgroundColor(parseColor(fColor[1]));


        //载入子颜色列表
        listView = findViewById(R.id.color_list);
        ZiListAdapter adapter = new ZiListAdapter(zColor, this);
        listView.setAdapter(adapter);

        //列表点击事件
        listView.setOnItemClickListener((adapterView, view, i, l) -> {
            //复制颜色值
            String color = zColor[i].substring(1);
            clipContent(this, color);
            sToast(this, "已复制：" + color);
        });


    }


    /**
     * 从上个界面接收数据
     */
    private void rxd() {
        fColor = getIntent().getExtras().getStringArray("fColor");
        zColor = getIntent().getExtras().getStringArray("zColor");
    }


}